﻿package mortal.game.scene3D.display3d.icon3d
{
    import baseEngine.basic.*;
    import flash.utils.*;
    import frEngine.pools.*;
    import frEngine.render.layer.*;
    import mortal.game.scene3D.*;

    public class Icon3DBigImg extends Object
    {
        private var _pool:Array;
        private var _iconMesh3d:Icon3DMesh;
        public var url:String;
        private var _lastDisposeTime:Number = 0;
        private var _disposeTime:Number = 60000;
        private var _hasCreateMaxNum:int = 0;

        public function Icon3DBigImg(param1:String, param2:RenderList)
        {
            this._pool = new Array();
            this.url = param1;
            this._iconMesh3d = FrObjectPool.getObject(Icon3DMesh, this, param2);
            this._iconMesh3d.reinit(this.url, param2);
            this._iconMesh3d.setLayer(Layer3DManager.IconLayer, false);
            this._iconMesh3d.render = Icon3DRender.instance;
            return;
        }// end function

        public function setRenderList(param1:RenderList) : void
        {
            if (this._iconMesh3d)
            {
                this._iconMesh3d.renderList = param1;
            }
            return;
        }// end function

        public function canDispose(param1:Number) : Boolean
        {
            if (param1 - this._lastDisposeTime > this._disposeTime && this._pool.length == this._hasCreateMaxNum)
            {
                return true;
            }
            return false;
        }// end function

        public function init(param1:GameScene3D) : void
        {
            param1.addChild(this._iconMesh3d);
            this._iconMesh3d.iconBg0.immediatelyUpload();
            return;
        }// end function

        public function reinit(param1:GameScene3D) : void
        {
            return;
        }// end function

        public function createIcon3D(param1:uint, param2:uint, param3:int, param4:int) : Icon3D
        {
            var _loc_5:Icon3D = null;
            if (this._pool.length > 0)
            {
                _loc_5 = this._pool.pop();
                _loc_5.show();
            }
            else
            {
                _loc_5 = new Icon3D(this.url);
                _loc_5.reInit(this._iconMesh3d.vectorList);
                var _loc_6:String = this;
                var _loc_7:* = this._hasCreateMaxNum + 1;
                _loc_6._hasCreateMaxNum = _loc_7;
            }
            _loc_5.setImgPos(param1, param2, param3, param4);
            return _loc_5;
        }// end function

        public function disposeIcon3D(param1:Icon3D) : void
        {
            if (this._pool.indexOf(param1) == -1)
            {
                this._pool.push(param1);
            }
            param1.hide();
            param1.setPosition(0, 0, 0);
            this._lastDisposeTime = getTimer();
            return;
        }// end function

        public function disposeAll() : void
        {
            this._iconMesh3d.dispose(false);
            this._pool = null;
            this._iconMesh3d = null;
            return;
        }// end function

    }
}
